import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView,
    },
    {
      path: '/admin',
      name: 'admin',
      redirect: '/admin/index',
      // 该种方式是路由的懒加载方式，import HomeView from '../views/HomeView.vue'这种是直接加载的方式，会导致初始加载体积较大
      component: () => import('@/layout/adminView.vue'),
      children: [
        {
          path: 'index',
          name: 'index',
          component: () => import('@/views/admin/indexView.vue'),
        },
        {
          path: 'user',
          name: 'user',
          component: () => import('@/views/admin/userAdmin/indexView.vue'),
        },
        {
          path: 'item1',
          name: 'item1',
          children: [
            {
              path: 'data',
              name: 'data',
              component: () => import('@/views/admin/item1/dataView.vue'),
            },
            {
              path: 'device',
              name: 'device',
              component: () => import('@/views/admin/item1/deviceView.vue'),
            }
          ]
        },
      ],
    },
  ],
})

export default router
